#include "stack.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <iostream>

// setuptestcase fixture
// setup everycase

class StackTest : public ::testing::Test {
  protected:
    virtual void SetUp() { std::cout << "setup executor" << std::endl; }
    virtual void TearDown() { std::cout << "teardown executor" << std::endl; }
    static void  SetUpTestCase() { std::cout << "setup by case" << std::endl; }
    static void  TearDownTestCase()
    {
        std::cout << "teardown by case" << std::endl;
    }
};

TEST_F(StackTest, newStack_can)
{
    Stack *s = NewStack();
    ASSERT_NE(s, nullptr);
    // ASSERT_EQ(s, NULL); // cpp use nullptr replace c NULL
}

TEST_F(StackTest, stackPush)
{
    Stack *s = NewStack();
    ASSERT_NE(s, nullptr);

    int    ele;
    STATUS ret = RET_STATUS_OK;

    ele = 8;
    ret = Push(s, ele);
    ASSERT_EQ(ret, RET_STATUS_OK);

    ele = 0;
    ret = Top(s, &ele);
    ASSERT_EQ(ele, 8);
    ASSERT_EQ(ret, RET_STATUS_OK);

    ele = 0;
    ret = Pop(s, &ele);
    ASSERT_EQ(ele, 8);
    ASSERT_EQ(ret, RET_STATUS_OK);

    ele = 0;
    ret = Top(s, &ele);
    ASSERT_EQ(ele, 0);
    ASSERT_EQ(ret, RET_STATUS_ERR);

    ele = 0;
    ret = Pop(s, &ele);
    ASSERT_EQ(ele, 0);
    ASSERT_EQ(ret, RET_STATUS_ERR);

    ret = DestoryStack(s);
    ASSERT_EQ(ret, RET_STATUS_OK);
}
